// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --protocol-version 70 --addresses Test=0x0 --accounts A B C --simulator

//# publish
module Test::M1 {
    use sui::coin::Coin;

    public struct Object has key, store {
        id: UID,
        value: u64,
    }

    fun foo<T: key, T2: drop>(_p1: u64, value1: T, _value2: &Coin<T2>, _p2: u64): T {
        value1
    }

    public entry fun create(value: u64, recipient: address, ctx: &mut TxContext) {
        transfer::public_transfer(
            Object { id: object::new(ctx), value },
            recipient
        )
    }
}

//# run Test::M1::create --sender A --args 0 @A

//# create-checkpoint

//# advance-epoch

//# run Test::M1::create --sender A --args 1 @B

//# create-checkpoint

//# advance-epoch

//# run Test::M1::create --sender C --args 2 @A

//# create-checkpoint

//# run-graphql
{
  transactionsA: transactions(filter: { affectedAddress: "@{A}" }) { ...TX }
  transactionsA_sentByC: transactions(filter: { affectedAddress: "@{A}", sentAddress: "@{C}" }) { ...TX }
  transactionsB: transactions(filter: { affectedAddress: "@{B}" }) { ...TX }
  transactionsC: transactions(filter: { affectedAddress: "@{C}" }) { ...TX }
}

fragment TX on TransactionConnection {
  pageInfo {
    startCursor
    endCursor
    hasPreviousPage
    hasNextPage
  }
  edges {
    cursor
    node {
      digest
      effects {
        checkpoint {
          sequenceNumber
          digest
        }
      }
    }
  }
}